package com.his.struts.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionServlet;

import com.his.struts.dao.function.FunctionDao;
import com.his.struts.dao.function.FunctionImp;
import com.his.struts.dao.hospitalInfo.HospitalInfoDao;
import com.his.struts.dao.hospitalInfo.HospitalInfoImp;
import com.his.struts.form.FunctionForm;
import com.his.struts.form.HospitalInfoForm;

/**
 * 初始化
 * @author xiaoweiliang
 *
 */
public class InitAction extends ActionServlet{

	/**
	 * 重写ActionServlet的process
	 */
	protected void process(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {		
		super.process(request, response);
	}

	/**
	 * 重写ActionServlet的init
	 */
	public void init() throws ServletException {
		HospitalInfoDao dao = new HospitalInfoImp(); 
		// 得到医院的信息
		HospitalInfoForm his = dao.getHospitalInfo();
		// 医院信息设置到全局
		this.getServletContext().setAttribute("his", his);
		
		FunctionDao functionDao = new FunctionImp();
		// 得到用户所拥有的功能
		List<FunctionForm> userFunction = functionDao.getUserFunction();
		// 把功能设置到全局
		this.getServletContext().setAttribute("userFunction", userFunction);
		
		// 得到用户所拥有的功能
		List<FunctionForm> doctorFunction = functionDao.getDoctorFunction();
		// 把功能设置到全局
		this.getServletContext().setAttribute("doctorFunction", doctorFunction);
		
		// 执行父类的init
		super.init();
	}

}
